/*
APPENDIX TABLE 6
Descriptive Statistics
*/

cd "$exhibits_path"

use "$data_path/main_analysis_file.dta", clear


	*creating necessary dummies
	tab gender, g(gender_dum)
	tab race2_harm, g(race_dum)
	tab cohabstatus, g(cohab_dum)
	
	g tenure_dum1 = inlist(longwork_yrs, 1,2) // 1 or less
	g tenure_dum2 = inlist(longwork_yrs, 3,4) // 2-3
	g tenure_dum3 = inlist(longwork_yrs, 5,6) // 4-5
	g tenure_dum4 = longwork_yrs==7 // 6+
	
	tab shift_ind, g(shift_ind_dum)
	
	

	*defining variables to be included in table
	global desc_vars age_text_clean gender_dum* race_dum* cohab_dum* kids eslhome enrolled hourwage_clean usualhours_clean tenure_dum* manager union shift_ind_dum*

**getting analytic sample from main results
eststo col1row3: mi est, esample(analytic_sample) post: reg benefits_paidsick c.pct_emps_psl_place $demog if  psl_law_places_hybd == 0, vce(cluster statelist)
count if analytic_sample==1
local table_sample = `r(N)'/10 // adjusting for multiple imputation

	
	*turning proportions into percentages
	foreach var of varlist gender_dum* race_dum* cohab_dum* kids eslhome enrolled tenure_dum* manager union shift_ind_dum*{
		replace `var' = `var' * 100 if `var' < 2
	}
	
	*getting table values
	estpost sum $desc_vars if analytic_sample==1 & !missing(benefits_paidsick)
	eststo descriptives
	
	estadd local sample_size "`table_sample'": descriptives

esttab descriptives using "$exhibits_path/Appendix Table 6.tex", ///
	 cells("mean(fmt(%9.0f))") collabels("Mean / \%") nonumber nostar noobs nogap noeqlines nomtitles ///
	refcat(age_text_clean "\textit{Demographic Characteristics}" gender_dum1 "\hspace{0.5cm} \textit{Gender}" race_dum1 "\hspace{0.5cm} \textit{Race/Ethnicity}" cohab_dum1 "\hspace{0.5cm} \textit{Cohabitation Status}" hourwage_clean "\\ \textit{Work Characteristics}" tenure_dum1 "\hspace{0.5cm} \textit{Job Tenure}" shift_ind_dum1 "\hspace{0.5cm} \textit{Industry}", nolabel) ///
	coeflabel(age_text_clean "\hspace{0.5cm} Age" gender_dum1 "\hspace{0.5cm} \hspace{0.5cm} Male" gender_dum2 "\hspace{0.5cm} \hspace{0.5cm} Female" race_dum1 "\hspace{0.5cm} \hspace{0.5cm} White" race_dum2 "\hspace{0.5cm} \hspace{0.5cm} Black" race_dum3 "\hspace{0.5cm} \hspace{0.5cm} Hispanic" race_dum4 "\hspace{0.5cm} \hspace{0.5cm} Other / 2+ Races"  cohab_dum1 "\hspace{0.5cm} \hspace{0.5cm} Married, Living with Spouse" cohab_dum2 "\hspace{0.5cm} \hspace{0.5cm} Living with Partner" cohab_dum3 "\hspace{0.5cm} \hspace{0.5cm} Not Living with Spouse/Partner" kids "\hspace{0.5cm} Has Children" eslhome "\hspace{0.5cm} Speaks Non-English Language at Home" enrolled "\hspace{0.5cm} Enrolled in School" hourwage_clean "\hspace{0.5cm} Hourly Wage (\textdollar)" usualhours_clean "\hspace{0.5cm} Usual Weekly Work Hours" tenure_dum1 "\hspace{0.5cm} \hspace{0.5cm} 1 Year or Less" tenure_dum2 "\hspace{0.5cm} \hspace{0.5cm} 2-3 Years" tenure_dum3 "\hspace{0.5cm} \hspace{0.5cm} 4-5 Years" tenure_dum4 "\hspace{0.5cm} \hspace{0.5cm} 6+ Years" union "\hspace{0.5cm} Union Member" manager "\hspace{0.5cm} Manager" shift_ind_dum1 "\hspace{0.5cm} \hspace{0.5cm} Building Supplies / Hardware" shift_ind_dum2 "\hspace{0.5cm} \hspace{0.5cm} General Merchandise" shift_ind_dum3 "\hspace{0.5cm} \hspace{0.5cm} Grocery Stores" shift_ind_dum4 "\hspace{0.5cm} \hspace{0.5cm} Auto Parts" shift_ind_dum5 "\hspace{0.5cm} \hspace{0.5cm} Clothing" shift_ind_dum6 "\hspace{0.5cm} \hspace{0.5cm} Home Furnishings" shift_ind_dum7 "\hspace{0.5cm} \hspace{0.5cm} Electronics Stores" shift_ind_dum8 "\hspace{0.5cm} \hspace{0.5cm} Restaurants / Food Service" shift_ind_dum9 "\hspace{0.5cm} \hspace{0.5cm} Pharmacies / Drug Stores" shift_ind_dum10 "\hspace{0.5cm} \hspace{0.5cm} Sporting Goods / Toy Stores" shift_ind_dum11 "\hspace{0.5cm} \hspace{0.5cm} Misc. Retail") ///
	scalar("sample_size \textit{N}") ///
	replace

	